//
//  ExchangeViewCell.swift
//  worldexchange
//
//  Created by xionghao on 2019/1/9.
//  Copyright © 2019 xionghao. All rights reserved.
//

import UIKit

protocol ExchangeViewCellDelegate {
    func onClickShowHide(section:Int)
    func onCellClick(section:Int,row:Int)
}


class ExchangeViewCell: QMUITableViewCell {

    
    
    static func loadView()->ExchangeViewCell {
        let view = Bundle.main.loadNibNamed("ExchangeViewCell", owner: nil, options: nil)?.last as! ExchangeViewCell
        return view
    }
    
    
    var delegate:ExchangeViewCellDelegate?
    @IBOutlet weak var demoationWrapper: UIView!
    @IBOutlet weak var demnomiationLabel: UILabel!
    @IBOutlet weak var selling: UILabel!
    @IBOutlet weak var buying: UILabel!
    @IBOutlet weak var currency: UILabel!
    @IBOutlet weak var icon: UIImageView!
    @IBOutlet weak var arrowIconView: UIView!
    
    var section:Int = 0
    var row:Int = 0
    
    override func awakeFromNib() {
        super.awakeFromNib()
        self.contentView.qmui_borderPosition = .bottom
        self.contentView.qmui_borderColor = UIColor.white
        self.contentView.qmui_borderWidth = 0.5
        // Initialization code
        let tap = UITapGestureRecognizer(target: self, action: #selector(wrapperClick))
         let tap1 = UITapGestureRecognizer(target: self, action: #selector(cellClick))
        self.demoationWrapper.addGestureRecognizer(tap)
        self.contentView.addGestureRecognizer(tap1)
        self.arrowIconView.isHidden = true
        self.icon.isHidden = true
    }
    
    @objc func wrapperClick(){
        if row == 0 {
             delegate?.onClickShowHide(section: section)
        }
       
    }
    
    @objc func cellClick(){
        delegate?.onCellClick(section: section, row: row)
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
    
    
    
}
